import axios from 'axios';
import FormData from 'form-data';
import fs from 'fs';


export const uploadImageToNet = (data) => {
    return new Promise((resolve, reject) => {
        console.log("data:" + data);
        //data: FormData
        var config = {
            method: 'post',
            url: 'http://localhost:8022/uploadImg',
            headers: {
                'Content-Type': 'multipart/form-data',
                // token:"5d356220-bda0-4e90-a0ee-6ffc053a984f",
                token: localStorage.getItem('token'),
                // ...data.getHeaders()
            },
            data: data
        };

        axios(config)
            .then(response => {
                // 成功响应的处理
                resolve(response.data); // 这里返回了你想要的data
            })
            .catch(error => {
                // 错误响应的处理
                reject(error);
            });
    })
}
